<extend name="Public/base" />
<block name="style"></block>
<block name="script">
<script src="__STATIC__/layui/layui.js"></script>
<script>
layui.use(['layer','form'], function(){
    var layer = layui.layer;
    var form = layui.form();
    form.verify({
        title: function(value, item){
            if(/^\d+\d+\d$/.test(value)){
                return '标题不能全为数字';
            }
        },
        description:function(value, item){
            if(/^\d+\d+\d$/.test(value)){
              return '描述不能全为数字';
            }
        },
        thumb:function(value, item){
            if(/^\d+\d+\d$/.test(value)){
              return '图片地址不能全为数字';
            }
        },
        url:function(value, item){
            if(/^\d+\d+\d$/.test(value)){
                return '数据地址不能全为数字';
            }
        },
    });
}); 
</script>
</block>
<block name="body">
    <div class="main-title">
       <if condition="$istype === 'add' ">
            <h2>新增内容列表</h2>
        <else />
            <h2>修改内容列表</h2>
        </if>
    </div>
    <if condition="$istype === 'add' ">
    <form id="form" action="{:U('add')}" method="post" class="form-horizontal layui-form">
    <else />
    <form id="form" action="{:U('edit')}" method="post" class="form-horizontal layui-form">
        <input type="hidden" name="id" value="{$data.id}">
    </if>
        <div id="tab1" class="tab-pane in tab1">
            <div class="form-item cf">
                <label class="item-label">标题：</label>
                <div class="controls">
                    <input lay-verify="required|title" <if condition="$istype === 'edit'">value="{$data.title}"</if> type="text" placeholder="请输入标题" class="text input-large" name="title">
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">描述：</label>
                <div class="controls">
                    <input lay-verify="required|description" <if condition="$istype === 'edit'">value="{$data.description}"</if> type="text" placeholder="请输入描述" class="text input-large" name="description">
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">图片地址：</label>
                <div class="controls">
                    <input lay-verify="required|thumb" <if condition="$istype === 'edit'">value="{$data.thumb}"</if> type="text" placeholder="请输入图片地址" class="text input-large" name="thumb">
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">数据地址：</label>
                <div class="controls">
                    <input lay-verify="required|url" <if condition="$istype === 'edit'">value="{$data.url}"</if> type="text" placeholder="请输入数据地址" class="text input-large" name="url">
                </div>
            </div>
            <input value="{$ad_id}" type="hidden" name="ad_id" />
            <input value="{$ad_name}" type="hidden" name="ad_name" />
            <div class="form-item cf">
                <button lay-submit class="btn submit-btn">确 定</button>
                <button class="btn btn-return" type="reset">重置</button>
            </div>
        </div>
    </form>
</block>
